package com.acquisition.controller;

import com.acquisition.common.entity.BaseResponse;
import com.acquisition.entity.RealTimeData;
import com.acquisition.service.RealTimeDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wang
 * @date 2023-04-18 21:00
 */

@RestController
public class RealTimeDataController {
    @Autowired
    RealTimeDataService realTimeDataService;


    /**
     * @Author wangxuan
     * @Description 保存对象
     * @Date 21:44 2023/4/18
     * @param realTimeData
     * @return BaseResponse<RealTimeData>
     **/
    @PostMapping("/saveRealTimeData")
    public BaseResponse<RealTimeData> save(RealTimeData realTimeData){
        int count = realTimeDataService.save(realTimeData);
        if (count>0){
            return BaseResponse.success("保存成功");
        }else {
            return BaseResponse.fail("保存失败");
        }
    }


    /**
         * @Author wangxuan
         * @Description 根据id更新
         * @Date 21:48 2023/4/18
         * @param realTimeData
         * @return BaseResponse<RealTimeData>
         **/
    @PostMapping("/updateRealTimeSave")
    public BaseResponse<RealTimeData> update(RealTimeData realTimeData){
        int target = realTimeDataService.update(realTimeData);
        if (target == 1){
            return BaseResponse.success("更新成功");
        }else {
            return BaseResponse.fail("更新失败");
        }
    }

}
